Skip to content

Improve toWarnDev matcher DX for unexpected warnings#12082

Merged
bvaughn merged 1 commit intofacebook:masterfrom
bvaughn:improve-unexpected-warning-diff-for-toWarnDev
Jan 23, 2018
Merged

Improve toWarnDev matcher DX for unexpected warnings#12082
bvaughn merged 1 commit intofacebook:masterfrom
bvaughn:improve-unexpected-warning-diff-for-toWarnDev

Conversation

@bvaughn
Copy link
Copy Markdown
Contributor

@bvaughn bvaughn commented Jan 23, 2018

Use jest-diff to format the warnings in a way that makes it easier to spot the differences.

Before

The differences before are hard to spot!
screen shot 2018-01-23 at 11 19 45 am

After

One unmatched expectation

If there's a single unmatched expectation, then just diff the individual strings:
screen shot 2018-01-23 at 11 15 00 am

Multiple unmatched expectations

Wrap in an array and do a diff. Let Jest decide which of the inner strings is closest. In some cases the diff might not be useful (if the warning was a completely different one than you were expecting) but in other cases the output can be meaningful:
screen shot 2018-01-23 at 11 14 34 am

No remaining expected warnings

Just print the unexpected warning by itself:
screen shot 2018-01-23 at 11 14 51 am

Use jest-diff to format the warnings in a way that makes it easier to spot the differences.
@bvaughn bvaughn force-pushed the improve-unexpected-warning-diff-for-toWarnDev branch from 903a4c8 to 45e82b0 Compare January 23, 2018 19:30
@bvaughn bvaughn merged commit d0e75dc into facebook:master Jan 23, 2018
@bvaughn bvaughn deleted the improve-unexpected-warning-diff-for-toWarnDev branch January 23, 2018 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants